package benchmark;

import java.util.List;

public class RepeatRun implements ITask {

	private int repeatTime;
	private int arraySize;
	private int[] array;
	
	/*
	 * 0. class name
	 * 1. repeat time
	 * 2. array size
	 */
	@Override
	public void init(List<String> param) {
		repeatTime = Integer.parseInt(param.get(1));
		arraySize = Integer.parseInt(param.get(2));
		array = new int[arraySize];
		for (int i = 0; i < arraySize; i++) {
			array[i] = (int) (System.nanoTime() % arraySize) + i;
//			array[i] = 777;
		}
	}

	@Override
	public String runTask() {
		int counter = repeatTime;
		long sum = 0;
		while (counter-- > 0) {
			for (int i = 0; i < array.length; i++) {
				sum += array[i];
			}
		}
		return Long.toString(sum);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
